SpringBoot官方文档翻译(二十四):监控额外的路径&禁用重启

20.2.3 Watching Additional Paths(监控额外的路径)

1
2
3
4
5
6
7
You may want your application to be restarted or reloaded when you make     
changes to files that are not on the classpath. To do so, use
the spring.devtools.restart.additional-paths property to configure
additional paths to watch for changes. You can use
the spring.devtools.restart.exclude property described earlier to
control whether changes beneath the additional paths trigger a full
restart or a live reload.

有时候,当您修改的文件不在类路径下的时候,您可能也需要您的应用重启或者重载。这样做,使用spring.devtools.restart.additional-paths属性去配置额外的路径去监控它是否发生了改变,并根据这个改变去重启。您可以使用spring.devtools.restart.exclude属性,如前所述
控制额外路径下的更改是否触发完整重新启动或实时重新加载。

20.2.4 Disabling Restart(禁用重启)

1
2
3
4
5
If you do not want to use the restart feature, you can disable     
it by using the spring.devtools.restart.enabled property. In
most cases, you can set this property in your application.properties 
(doing so still initializes the restart classloader, but it does not
watch for file changes).

如果您不喜欢用重启功能,您可以通过spring.devtools.restart.enabled属性禁用它。在大部分情况下,您可以在您的application.properties中设置它。(如果设置了它,始终会初始化“重启”类加载器,但是不监控文件的修改)。

1
2
3
4
If you need to completely disable restart support (for example,     
because it does not work with a specific library), you need to set
the spring.devtools.restart.enabled System property to false before
calling SpringApplication.run(… ), as shown in the following example:

如果您想完全禁止重启功能(举个例子,它不能用于某个特殊的库),您需要在调用SpringApplication.run(… )之前设置spring.devtools.restart.enabled系统属性为fasle,如下:

1
2
3
4
public static void main(String[] args) {
System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(MyApp.class, args);
}

分享到